package nova

// 应用
const (
	APP_MSG_CENTER   = "fis-message-center"
	APP_MSG_CHANNEL  = "arch-msg-channel"
	APP_PUSH_CHANNEL = "arch-push-channel"
	APP_USER_CENTER  = "fis-ucenter"
	APP_AMP_SYSTEM   = "fis-amp"
	APP_SCONF_API    = "fis-sconf"
	APP_PASSPORT     = "fis-passport"
	APP_ACCOUNT      = "fis-account"

	AppArchUser      = "arch-user"
	AppArchUCenter   = "arch-ucenter"
	AppMsgMiddleware = "arch-msg-middleware"

	AppFbsEventV1   = "fbs-event-v1"
	AppFbsCcV1      = "fbs-cc-v1"
	AppFbsCcV2      = "fbs-cc-v2"
	AppFbsLmsApi    = "fbs-lms-api"
	AppFbsPApiV1    = "fbs-papi-v1"
	AppFbsPApiV2    = "fbs-papi-v2"
	AppFbsRefundApi = "fbs-refund-api"
	AppFbsCss       = "fbs-css"
	AppFbsApp       = "fbs-app"

	AppFisVoucher      = "fis-voucher-api"
	AppFisCapacity     = "fis-capacity"
	AppBusinessUserApi = "business-user-api"
	AppFisBusinessUser = "fis-business-user"

	AppRstTeacherApi         = "rst-teacher-api"
	AppBizTeacherService     = "biz-teacher-service"
	AppRstCalendarApi        = "rst-student-calendar-api"
	AppFisJobsApi            = "fis-jobs-api"
	AppFisAccountApi         = "fis-account-api"
	AppFisAmpApi             = "fis-amp-api"
	AppAmpApi                = "amp-api"
	AppFisOutboundCallCenter = "fis-outbound-call-center"
	AppArchHades             = "arch-hades"
	AppFisMkeSearchApi       = "fis-mke-search-api"
	AppDmcIssues             = "dmc.test-dahai.com"
	AppZkAuthService         = "auth-service"
)

const (
	addrPrefix = "http://"
)

var (
	remoteAddr map[string]string
)

// 初始化配置
func initConfigCenter(namespace string) {
	remoteAddr = make(map[string]string)
	if appEnv == DeployEnvProd {
		initProdAddr()
	} else if appEnv == DeployEnvPre {
		initProdAddr()
	} else if appEnv == DeployEnvTest {
		initTestAddr()
	} else if appEnv == DeployEnvDev {
		initDevAddr(namespace)
	}
}

// 生产环境
func initProdAddr() {
	remoteAddr[APP_MSG_CENTER] = addrPrefix + APP_MSG_CENTER
	remoteAddr[APP_MSG_CHANNEL] = addrPrefix + APP_MSG_CHANNEL
	remoteAddr[APP_PUSH_CHANNEL] = addrPrefix + APP_PUSH_CHANNEL
	remoteAddr[APP_USER_CENTER] = addrPrefix + APP_USER_CENTER
	remoteAddr[APP_AMP_SYSTEM] = addrPrefix + APP_AMP_SYSTEM
	remoteAddr[APP_SCONF_API] = addrPrefix + APP_SCONF_API
	remoteAddr[APP_PASSPORT] = addrPrefix + APP_PASSPORT
	remoteAddr[APP_ACCOUNT] = addrPrefix + APP_ACCOUNT

	remoteAddr[AppArchUser] = addrPrefix + AppArchUser
	remoteAddr[AppArchUCenter] = addrPrefix + AppArchUCenter
	remoteAddr[AppMsgMiddleware] = addrPrefix + AppMsgMiddleware

	remoteAddr[AppFbsEventV1] = addrPrefix + AppFbsEventV1
	remoteAddr[AppFbsCcV1] = addrPrefix + AppFbsCcV1
	remoteAddr[AppFbsCcV2] = addrPrefix + AppFbsCcV2
	remoteAddr[AppFbsLmsApi] = addrPrefix + AppFbsLmsApi
	remoteAddr[AppFbsPApiV1] = addrPrefix + AppFbsPApiV1
	remoteAddr[AppFbsPApiV2] = addrPrefix + AppFbsPApiV2
	remoteAddr[AppFbsRefundApi] = addrPrefix + AppFbsRefundApi
	remoteAddr[AppFbsCss] = addrPrefix + AppFbsCss
	remoteAddr[AppFbsApp] = addrPrefix + AppFbsApp

	remoteAddr[AppFisVoucher] = addrPrefix + AppFisVoucher
	remoteAddr[AppFisCapacity] = addrPrefix + AppFisCapacity
	remoteAddr[AppBusinessUserApi] = addrPrefix + AppBusinessUserApi
	remoteAddr[AppFisBusinessUser] = addrPrefix + AppFisBusinessUser

	remoteAddr[AppRstTeacherApi] = addrPrefix + AppRstTeacherApi
	remoteAddr[AppBizTeacherService] = addrPrefix + AppBizTeacherService
	remoteAddr[AppRstCalendarApi] = addrPrefix + AppRstCalendarApi
	remoteAddr[AppFisJobsApi] = addrPrefix + AppFisJobsApi
	remoteAddr[AppFisAccountApi] = addrPrefix + AppFisAccountApi
	remoteAddr[AppFisAmpApi] = addrPrefix + AppFisAmpApi
	remoteAddr[AppAmpApi] = addrPrefix + AppAmpApi
	remoteAddr[AppFisOutboundCallCenter] = addrPrefix + AppFisOutboundCallCenter
	remoteAddr[AppArchHades] = addrPrefix + AppArchHades
	remoteAddr[AppFisMkeSearchApi] = addrPrefix + AppFisMkeSearchApi

	remoteAddr[AppDmcIssues] = addrPrefix + AppDmcIssues
	remoteAddr[AppZkAuthService] = addrPrefix + AppZkAuthService
}

// 测试环境
func initTestAddr() {
	remoteAddr[APP_MSG_CENTER] = addrPrefix + APP_MSG_CENTER
	remoteAddr[APP_MSG_CHANNEL] = addrPrefix + APP_MSG_CHANNEL
	remoteAddr[APP_PUSH_CHANNEL] = addrPrefix + APP_PUSH_CHANNEL
	remoteAddr[APP_USER_CENTER] = addrPrefix + APP_USER_CENTER
	remoteAddr[APP_AMP_SYSTEM] = addrPrefix + APP_AMP_SYSTEM
	remoteAddr[APP_SCONF_API] = addrPrefix + APP_SCONF_API
	remoteAddr[APP_PASSPORT] = addrPrefix + APP_PASSPORT
	remoteAddr[APP_ACCOUNT] = addrPrefix + APP_ACCOUNT

	remoteAddr[AppArchUser] = addrPrefix + AppArchUser
	remoteAddr[AppArchUCenter] = addrPrefix + AppArchUCenter
	remoteAddr[AppMsgMiddleware] = addrPrefix + AppMsgMiddleware

	remoteAddr[AppFbsEventV1] = addrPrefix + AppFbsEventV1
	remoteAddr[AppFbsCcV1] = addrPrefix + AppFbsCcV1
	remoteAddr[AppFbsCcV2] = addrPrefix + AppFbsCcV2
	remoteAddr[AppFbsLmsApi] = addrPrefix + AppFbsLmsApi
	remoteAddr[AppFbsPApiV1] = addrPrefix + AppFbsPApiV1
	remoteAddr[AppFbsPApiV2] = addrPrefix + AppFbsPApiV2
	remoteAddr[AppFbsRefundApi] = addrPrefix + AppFbsRefundApi
	remoteAddr[AppFbsCss] = addrPrefix + AppFbsCss
	remoteAddr[AppFbsApp] = addrPrefix + AppFbsApp

	remoteAddr[AppFisVoucher] = addrPrefix + AppFisVoucher
	remoteAddr[AppFisCapacity] = addrPrefix + AppFisCapacity
	remoteAddr[AppBusinessUserApi] = addrPrefix + AppBusinessUserApi
	remoteAddr[AppFisBusinessUser] = addrPrefix + AppFisBusinessUser

	remoteAddr[AppRstTeacherApi] = addrPrefix + AppRstTeacherApi
	remoteAddr[AppBizTeacherService] = addrPrefix + AppBizTeacherService
	remoteAddr[AppRstCalendarApi] = addrPrefix + AppRstCalendarApi
	remoteAddr[AppFisJobsApi] = addrPrefix + AppFisJobsApi
	remoteAddr[AppFisAccountApi] = addrPrefix + AppFisAccountApi
	remoteAddr[AppFisAmpApi] = addrPrefix + AppFisAmpApi
	remoteAddr[AppAmpApi] = addrPrefix + AppAmpApi
	remoteAddr[AppFisOutboundCallCenter] = addrPrefix + AppFisOutboundCallCenter
	remoteAddr[AppArchHades] = addrPrefix + AppArchHades
	remoteAddr[AppFisMkeSearchApi] = addrPrefix + AppFisMkeSearchApi
	remoteAddr[AppDmcIssues] = addrPrefix + AppDmcIssues
	remoteAddr[AppZkAuthService] = addrPrefix + AppZkAuthService
}

// 开发环境
func initDevAddr(namespace string) {
	prefix := addrPrefix + namespace + "."
	suffix := ".internal.test-dahai.com"
	remoteAddr[APP_MSG_CENTER] = prefix + APP_MSG_CENTER + suffix
	remoteAddr[APP_MSG_CHANNEL] = prefix + APP_MSG_CHANNEL + suffix
	remoteAddr[APP_PUSH_CHANNEL] = prefix + APP_PUSH_CHANNEL + suffix
	remoteAddr[APP_USER_CENTER] = prefix + APP_USER_CENTER + suffix
	remoteAddr[APP_AMP_SYSTEM] = prefix + APP_AMP_SYSTEM + suffix
	remoteAddr[APP_SCONF_API] = prefix + APP_SCONF_API + suffix
	remoteAddr[APP_PASSPORT] = prefix + APP_PASSPORT + suffix
	remoteAddr[APP_ACCOUNT] = prefix + APP_ACCOUNT + suffix

	remoteAddr[AppArchUser] = prefix + AppArchUser + suffix
	remoteAddr[AppArchUCenter] = prefix + AppArchUCenter + suffix
	remoteAddr[AppMsgMiddleware] = prefix + AppMsgMiddleware + suffix

	remoteAddr[AppFbsEventV1] = prefix + AppFbsEventV1 + suffix
	remoteAddr[AppFbsCcV1] = prefix + AppFbsCcV1 + suffix
	remoteAddr[AppFbsCcV2] = prefix + AppFbsCcV2 + suffix
	remoteAddr[AppFbsLmsApi] = prefix + AppFbsLmsApi + suffix
	remoteAddr[AppFbsPApiV1] = prefix + AppFbsPApiV1 + suffix
	remoteAddr[AppFbsPApiV2] = prefix + AppFbsPApiV2 + suffix
	remoteAddr[AppFbsRefundApi] = prefix + AppFbsRefundApi + suffix
	remoteAddr[AppFbsCss] = prefix + AppFbsCss + suffix
	remoteAddr[AppFbsApp] = prefix + AppFbsApp + suffix

	remoteAddr[AppFisVoucher] = prefix + AppFisVoucher + suffix
	remoteAddr[AppFisCapacity] = prefix + AppFisCapacity + suffix
	remoteAddr[AppBusinessUserApi] = prefix + AppBusinessUserApi + suffix
	remoteAddr[AppFisBusinessUser] = prefix + AppFisBusinessUser + suffix

	remoteAddr[AppRstTeacherApi] = prefix + AppRstTeacherApi + suffix
	remoteAddr[AppBizTeacherService] = prefix + AppBizTeacherService + suffix
	remoteAddr[AppRstCalendarApi] = prefix + AppRstCalendarApi + suffix
	remoteAddr[AppFisJobsApi] = prefix + AppFisJobsApi + suffix
	remoteAddr[AppFisAccountApi] = prefix + AppFisAccountApi + suffix
	remoteAddr[AppFisAmpApi] = prefix + AppFisAmpApi + suffix
	remoteAddr[AppAmpApi] = prefix + AppAmpApi + suffix
	remoteAddr[AppFisOutboundCallCenter] = prefix + AppFisOutboundCallCenter + suffix
	remoteAddr[AppArchHades] = prefix + AppArchHades + suffix
	remoteAddr[AppFisMkeSearchApi] = prefix + AppFisMkeSearchApi + suffix
	remoteAddr[AppDmcIssues] = prefix + AppDmcIssues + suffix
	remoteAddr[AppZkAuthService] = prefix + AppZkAuthService + suffix
}

// 获取远程应用配置地址
func GetRemoteAddr(app string) string {
	return remoteAddr[app]
}

// 所有远程应用配置地址
func ListRemoteAddr() map[string]string {
	return remoteAddr
}
